package com.panda.pandawash.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.panda.pandawash.R;
import com.panda.pandawash.api.ApplicationConstant;
import com.panda.pandawash.view.StatusBarCompat;


/**
 * Created by gaowf on 2017/2/21.
 */

public class FeedbackDetailsActivity extends Activity implements View.OnClickListener {
    private SharedPreferences mSp;
    //private Button mFeedbackBt;
    private TextView mFeedbackTitle;
    private TextView mFeedbackContent;
    private TextView mFeedbackTime;
    private Intent mIntent;
    private ImageView mBack;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.feedback_details_activity);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            StatusBarCompat.compat(this, getResources().getColor(R.color.colorPrimary));
        }
        //mFeedbackBt = (Button) findViewById(R.id.feedback_submit_bt);
        mFeedbackTitle = (TextView) findViewById(R.id.feedback_title_in_content);
        mFeedbackContent = (TextView) findViewById(R.id.feedback_content_in_content);
        mFeedbackTime = (TextView) findViewById(R.id.feedback_time_tv);
        mBack = (ImageView) findViewById(R.id.feedback_activity_return);
        //mFeedbackBt.setOnClickListener(this);
        mBack.setOnClickListener(this);
        mIntent = getIntent();

        mSp = getSharedPreferences(ApplicationConstant.SP_NAME, MODE_PRIVATE);

        query();
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }


    @Override
    public void onClick(View v) {
        if(v.getId()==R.id.feedback_activity_return){
            finish();
        }
        //else if(v.getId()==R.id.feedback_submit_bt){
            //String title = mFeedbackTitleEt.getText().toString().trim();
            //String content = mFeedbackContentEt.getText().toString().trim();
            //if (!"".equals(title) || !"".equals(content)) {
                //postFeedbackInfo(title,content);
                //finish();
            //}
        //}
    }

    private void query(){
        String title = mIntent.getStringExtra(ApplicationConstant.SP_FEEDBACK_TITLE);
        Log.d("binbo","title = " + title);
        String content = mSp.getString(title,"empty");

        mFeedbackTitle.setText(title);
        try {
            String thisTime = content.substring(0, 19);
            String thisContent = content.substring(19);
            mFeedbackContent.setText(thisContent);
            mFeedbackTime.setText(thisTime);
        }catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }

    }
}
